package xyz.pro5books.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xyz.pro5books.pojo.BookTemp;
import xyz.pro5books.service.BookTempService;
import xyz.pro5books.vo.PageResult;
import xyz.pro5books.vo.SysResult;

@RestController
@CrossOrigin
@RequestMapping("/bookTemp")
public class BookTempController {

    @Autowired
    private BookTempService bookTempService;

    //获取审核书籍信息
    @GetMapping("/getBookTempList")
    public SysResult getBookTemp(PageResult pageResult){
        pageResult = bookTempService.getBookTempList(pageResult);
        return SysResult.success(pageResult);
    }

    @GetMapping("{id}")
    public SysResult getBookTemp(@PathVariable Integer id){
        BookTemp bookTemp = bookTempService.getBookTemp(id);
        return SysResult.success(bookTemp);
    }

    @PostMapping("/addBookTemp")
    public SysResult addBookTemp(@RequestBody BookTemp bookTemp){

        bookTempService.addBookTemp(bookTemp);
        return SysResult.success();
    }
    //待审核的书籍在审核通过后在审核表里要删除掉
    @DeleteMapping("/{id}")
    public SysResult deleteBookTemp(@PathVariable Integer id){
        bookTempService.deleteBookTemp(id);
        return SysResult.success();
    }

    @PutMapping("/updateBookTemp")
    public SysResult updateBookTemp(@RequestBody BookTemp bookTemp){
        bookTempService.updateBookTemp(bookTemp);
        return SysResult.success();
    }
}
